<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
      
<h:head>
	<title>Search Transports</title>
</h:head>
<h:body>
<p:panel>
<h:link outcome="index" value="Home" /> <br /> 
		<h:link outcome="indexPackages" value="Packages section" /> <br /> 
        <h:link outcome="indexBasicProduct" value="Basic Products section" /> <br /> 
       	<h:link outcome = "createPackage" value = "Go To The Package!"/>
 </p:panel>
<h:form id="form">
	
 <p:dataTable  var="transport" value="#{transportSearch.transports}" 
 				rowKey="#{transport.id}" paginator="true"  
                
                id="transportsTable"
                emptyMessage="There are NO Transports"
                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15"
				
				cellSeparator="true"
				resizableColumns="true">  
  
  
      	<p:column headerText="ID" sortBy="id" filterBy="id" id="id">  
            #{transport.id}
        </p:column>   

      	<p:column headerText="From" sortBy="fromPlace" filterBy="fromPlace" id="fromPlace">  
            #{transport.fromPlace}
        </p:column> 
        
        <p:column headerText="To" sortBy="toPlace" filterBy="toPlace" id="toPlace">  
            #{transport.toPlace}
        </p:column>  

      	<p:column headerText="Departure Date" sortBy="departureDate" filterBy="departureDate" id="departureDate">  
            #{transport.departureDate}
        </p:column>   

      	<p:column headerText="Passengers" sortBy="passengers" filterBy="passengers" id="passengers">  
            #{transport.passengers}
        </p:column>

      	<p:column headerText="Type" sortBy="type" filterBy="type" id="type">  
            #{transport.type}
        </p:column>
        
        <p:column headerText="Price" sortBy="price" filterBy="price" id="price">  
            #{transport.price}
        </p:column>

   		<p:column style="width:32px">  
   		     <f:facet name="header">
   					<input type='button' value="*" readonly="readonly" title='View Details!' />
   				</f:facet >
             <p:commandButton update=":dlgForm:transDetGrid" oncomplete="transDialog.show()"  
                     image="ui-icon ui-icon-search" style="width:32px"> 
                 <f:setPropertyActionListener value="#{transport}"  
                     target="#{transportSearch.currentTransport}" />  
             </p:commandButton>  
         </p:column> 
         <p:column style="width:32px" >
         	    <f:facet name="header">
   					<input type='button' value="*" readonly="readonly" title='Delete Product!' />
   				</f:facet >
                      <p:commandButton id="transDelete" style="width:32px" icon="ui-icon-trash" 
                      
             update=":form:transportsTable"  ajax="false" action="#{transportSearch.deleteTransport()}">
                               <f:setPropertyActionListener value="#{transport}"  
                     target="#{transportSearch.currentTransport}" />  
                     </p:commandButton>
         </p:column>  
	                	<p:column style="width:32px">
	                	              <f:facet name="header">
   					<input type='button' value="*" readonly="readonly" title='Add To The Package As Departure Transport!' />
   				</f:facet >
	                      <p:commandButton style="width:32px" icon="ui-icon-disk"
	                      		onmouseover="Add to Package As Departure" 
	       		        		 action="#{transportSearch.addToPackAsDeparture()}"  ajax="false" update=":form:transportsTable">
	                                                    <f:setPropertyActionListener value="#{transport}"  
	                     target="#{transportSearch.currentTransport}" />  
	                     </p:commandButton>
	                   	 </p:column>
	                   	
	                   	<p:column style="width:32px">
	                   		                	              <f:facet name="header">
   					<input type='button' value="*" readonly="readonly" title='Add To The Package As Return Transport!' />
   				</f:facet >
	                      <p:commandButton style="width:32px" icon="ui-icon-disk"
	                      		onmouseover="Add to Package As Return" 
	       		        		 action="#{transportSearch.addToPackAsReturn()}"  ajax="false" update=":form:transportsTable">
	                     <f:setPropertyActionListener value="#{transport}"  
	                     target="#{transportSearch.currentTransport}" />  
	                     </p:commandButton>
	                     </p:column>
	                     
	                            <p:column style="width:32px">
                 <f:facet name="header">
   					<input type='button' value="*" readonly="readonly" title='Add to Modify!' />
   				</f:facet >	  
 			  <p:commandButton style="width:32px"  icon="ui-icon-gear"
       		        		 action="#{transportSearch.passToModified()}" ajax="false"
       		        		 type="submit" process="@this"
       		        		 oncomplete="modDialog.show()"
       		        		 update=":pan:modGrid" >
               <f:setPropertyActionListener value="#{transport}"  
                     target="#{transportSearch.currentTransport}" 
                     />  
              </p:commandButton>
              
       	</p:column> 
        
        
   </p:dataTable>
  
 </h:form>
   
  	<p:dialog id="transDialog" header="Details" widgetVar="transDialog" resizable="true"  
              width="600" height="340" dynamic="true" showEffect="exlpode" hideEffect="explode" closeOnEscape="true">  
       		 <h:form id="dlgForm">
         <h:panelGrid id="transDetGrid" columns="2" cellpadding="4">  
  
        	   								
					<h:outputLabel>Available*:</h:outputLabel>
					<p:selectBooleanCheckbox  
					value="#{transportSearch.currentTransport.available}" disabled="true"/>
					
	
					<h:outputLabel>Disponibility*:</h:outputLabel>
					<h:outputText value="#{transportSearch.currentTransport.disponibility}" />
	
					<h:outputLabel>Price*:</h:outputLabel>
					<h:outputText value="#{transportSearch.currentTransport.price}" />
					

					<h:outputLabel>Transport Type*:</h:outputLabel>
					<h:outputText value="#{transportSearch.currentTransport.type}" />
				
		
					<h:outputLabel>Number of Passengers*:</h:outputLabel>
					<h:outputText value="#{transportSearch.currentTransport.passengers}" />

					<h:outputLabel>Class*:</h:outputLabel>
					<h:outputText id="classNumber" value="#{transportSearch.currentTransport.classNumber}"/>
	
					<h:outputLabel>From (Place)*:</h:outputLabel>
					<h:outputText value="#{transportSearch.currentTransport.fromPlace}" />
	
					<h:outputLabel>To (Place)*:</h:outputLabel>
					<h:outputText  value="#{transportSearch.currentTransport.toPlace}" />
	
					<h:outputLabel>Departure Date*:</h:outputLabel>
					<p:calendar value="#{transportSearch.currentTransport.departureDate}" disabled="true"  id="departureDate"/>
				
	
					<h:outputLabel>Departure Time*:</h:outputLabel>
					<p:calendar  disabled = "true" value="#{transportSearch.currentTransport.departureTime}"  pattern="HH:mm" timeOnly="true" />					
					
					<h:outputLabel>Departure Company:</h:outputLabel>
					<h:outputText value="#{transportSearch.currentTransport.company}" />
					
					<h:outputLabel>Flight ID:</h:outputLabel>
					<h:outputText value="#{transportSearch.currentTransport.flightId}" />
            
		
        </h:panelGrid> 
        
		</h:form>
		
		</p:dialog>
	
	<p:panel id="pan" header="Modify!">
		<h:form>
			<h:panelGrid columns="3" id="redGrid">
			
						<h:outputLabel for="available">Available*:</h:outputLabel>
					<p:selectBooleanCheckbox id="available" value="#{transportSearch.modifiedTransport.available}" />
					<h:message for="available" />
	
					<h:outputLabel for="disponibility">Disponibility*:</h:outputLabel>
					<p:inputMask id="disponibility" value="#{transportSearch.modifiedTransport.disponibility}" />
					<h:message for="disponibility" />
	
					<h:outputLabel for="price">Price*:</h:outputLabel>
					<p:inputMask id="price" value="#{transportSearch.modifiedTransport.price}" />
					<h:message for="price" />

					<h:outputLabel for="type">Transport Type*:</h:outputLabel>
					<p:inputMask id="type" value="#{transportSearch.modifiedTransport.type}" />
					<h:message for="type" />
		
					<h:outputLabel for="passengers">Number of Passengers*:</h:outputLabel>
					<p:inputMask id="passengers" value="#{transportSearch.modifiedTransport.passengers}"/>
					<h:message for="passengers" />

					<h:outputLabel for="classNumber">Class*:</h:outputLabel>
					<p:inputMask id="classNumber" value="#{transportSearch.modifiedTransport.classNumber}"/>
					<h:message for="classNumber" />
	
					<h:outputLabel for="fromPlace">From (Place)*:</h:outputLabel>
					<p:inputMask id="fromPlace" value="#{transportSearch.modifiedTransport.fromPlace}" />
					<h:message for="fromPlace" />
	
					<h:outputLabel for="toPlace">To (Place)*:</h:outputLabel>
					<p:inputMask id="toPlace" value="#{transportSearch.modifiedTransport.toPlace}" />
					<h:message for="toPlace" />
	
					<h:outputLabel for="departureDate">Departure Date*:</h:outputLabel>
					<p:calendar value="#{transportSearch.modifiedTransport.departureDate}"  id="departureDate"/>
					<h:message for="departureDate" />
	
					<h:outputLabel for="departureTime">Departure Time*:</h:outputLabel>
					<p:calendar id="departureTime" value="#{transportSearch.modifiedTransport.departureTime}"  pattern="HH:mm" timeOnly="true" />
					<h:message for="departureTime" />
					
					
					<h:outputLabel for="company">Departure Company:</h:outputLabel>
					<p:inputMask id="company" value="#{transportSearch.modifiedTransport.company}" />
					<br/>
	
					<h:outputLabel for="flightId">Flight ID:</h:outputLabel>
					<p:inputMask id="flightId"  value="#{transportSearch.modifiedTransport.flightId}" />
			
					
	
			</h:panelGrid>
			
			    <p:commandButton disabled="transportSearch.modifiedTransport.id==null" value="Save" icon="ui-icon-disk" ajax="false"  action="#{transportSearch.modifyTransport()}"  type= "submit"   />
			
		</h:form>
	</p:panel>
	</h:body>
		
</html>